package smart
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	import smart.injector.Injector;
	import smart.utils.SingletonClassFactory;
	import smart.utils.SharedEvtDispacher;
	
	/**
	 *  Core part of framework.it connect the actors,commands,and mediators
	 * @author Eric li
	 * 
	 */
	public class CoreConnector 
	{
		public var event:Event;
		public var injector:Injector;
		public var selfEvtDispatcher:EventDispatcher;
		[Inject]
		public var eventDispatcher:SharedEvtDispacher;
		public function CoreConnector(target:IEventDispatcher=null)
		{
			super();
			injector=SingletonClassFactory.getSingletonInstance(Injector) as Injector;
		/*	injector.mapClass(SharedEvtDispacher,SharedEvtDispacher);
			injector.mapClass(MediatorMap,MediatorMap);*/
			selfEvtDispatcher=new EventDispatcher();  
			injector.injectTarget(this);
		}
		
		
		public function addSelfEventListener(type:String,listerner:Function):void
		{
			selfEvtDispatcher.addEventListener(type,listerner);
		}
		
		public function removeSelfEventListener(type:String,listerner:Function):void
		{
			selfEvtDispatcher.removeEventListener(type,listerner);
		}
		public function dispatchSelfEvent(event:Event):void
		{
			selfEvtDispatcher.dispatchEvent(event);
		}
		
		public function dispatchEvent(e:Event):void
		{
			eventDispatcher.dispatchEvent(e);
		}
		

		public function dispatch(e:Event):void
		{
			eventDispatcher.dispatchEvent(e);
		}
		
		
	}
}